package com.nbjtjc.safe.api.emg.handle;

import com.nbjtjc.safe.bean.Result;
import com.nbjtjc.safe.model.emg.handle.EmgHandleList;
import com.nbjtjc.safe.service.emg.handle.EmgHandleListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping(value = "/emgHandleList")
@CrossOrigin("*")
public class EmgHandleListController  {

    @Autowired
    private EmgHandleListService emgHandleListService;

    @RequestMapping(value = "/addOrUpdate",method = {RequestMethod.POST})
    public Result add( @RequestBody EmgHandleList emgHandleList){
        Result result=new Result();
        try {
            result=emgHandleListService.add(emgHandleList);
        } catch (Exception e) {
            e.printStackTrace();
            result.setFalse(e.getMessage());
        }
        return result;
    }

    @RequestMapping(value = "/delete",method = {RequestMethod.POST})
    public Result delete(@RequestBody int id) {
        Result result=new Result();
        try {
            result=emgHandleListService.delete(id);
        } catch (Exception e) {
            e.printStackTrace();
            result.setFalse(e.getMessage());
        }
        return result;
    }

    @RequestMapping(value = "/find",method = {RequestMethod.POST})
    public Result find(@RequestBody EmgHandleList emgHandleList) {
        Result result=new Result();
        try {
            result=emgHandleListService.find(emgHandleList);
        } catch (Exception e) {
            e.printStackTrace();
            result.setFalse(e.getMessage());
        }
        return result;
    }
}
